package com.zyz.J_枚举;

/**
 * @author: vick
 * @Date: 2025/3/27
 * @Description:  车位状态 枚举类
 * @version: 1.0
 */
public enum ParkStatusEnum {
    //ctrl+shit+u 快速变更大小写
    UNKONWN(-1, "未知状态"),
    APPEARANCE(1, "出场"),
    ENTRY(2, "进场"),
    OPENSTOPE(3, "空场"),
    PRESENT(4, "在场");

    private final int code;
    private final String desc;

    ParkStatusEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    //根据 code 找到对应的 desc
    public static String getDescription(int code) {
        ParkStatusEnum[] values = values();
        for (ParkStatusEnum ps : values) {
            if (ps.code == code) {
                return ps.desc;
            }
        }
        return UNKONWN.getDesc() + "(" + code + ")";
    }
}
